<template>
  <div>
    <searchBar placeHolder='请输入维修厂名称'
               @handleSearch='init' />
    <el-table :data="tableData">
      <el-table-column align="center"
                       label="订单编号"
                       prop="odd_number">
      </el-table-column>
      <el-table-column align="center"
                       label="维修厂名称"
                       prop="company">
      </el-table-column>
      <el-table-column align="center"
                       label="联系电话"
                       prop="phone">
      </el-table-column>
      <el-table-column align="center"
                       label="负责人"
                       prop="leader">
      </el-table-column>
      <el-table-column align="center"
                       label="提现金额"
                       prop="money">
      </el-table-column>
      <el-table-column align="center"
                       label="申请时间"
                       prop="create_time">

      </el-table-column>
      <el-table-column align="center"
                       label="审核时间"
                       prop="audit_time">
      </el-table-column>
      <el-table-column align="center"
                       label="审核人"
                       prop="audit_person">
      </el-table-column>
      <el-table-column align="center"
                       label="订单状态">
        <template slot-scope="scope">
          <el-button type="text"
                     @click='Query(scope.row)'>点击查询</el-button>
        </template>
      </el-table-column>
    </el-table>
    <v-dialog :title="OrderState && OrderState.msg"
              :show.sync='OrderStateVisible'
              width='30%'>
      <el-form style="text-align:right"
               v-if='OrderState.data'>
        <el-form-item label="商户单号:">
          {{OrderState.data.partner_trade_no}}
        </el-form-item>
        <el-form-item label="代付金额:">
          {{OrderState.data.amount/100}}元
        </el-form-item>
        <el-form-item label="手续费金额:">
          {{OrderState.data.cmms_amt/100}}元
        </el-form-item>
        <el-form-item :label="OrderState.code!==2 ? '成功时间' : '失败时间'">
          {{OrderState.data.pay_succ_time}}
        </el-form-item>
      </el-form>
    </v-dialog>
    <v-pagination :total='total'
                  :page.sync='page'
                  @pagination='init' />
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      total: 0, //总页数
      page: 1,//当前页 
      OrderStateVisible: false,
      OrderState: {}
    }
  },
  methods: {
    async init (data) {
      try {
        const res = await this.api.Shop_adoptList(Object.assign({}, data, { page: this.page, key: data && data.search }))
        this.tableData = res.data.list || []
        this.total = res.data.rows || 0
      } catch (err) {
        console.log(err)
        this.$message.error('接口报错,请联系管理员')
      }
    },
    async Query ({ odd_number }) {  //查询订单状态
      try {
        const res = await this.api.selCashStatus({ odd_number: odd_number })
        if (res.code == 0) {
          this.$message.error(res.msg)
        } else {
          this.OrderState = res || {}
          this.OrderStateVisible = true

        }
      } catch (err) {
        throw (err)
      }
    }

  },
  mounted () {
    this.init()
  }
}
</script>

<style scoped lang='scss'>
</style>
